using System;
using System.Collections.Generic;
using System.Text;

namespace LSO
{
    static class LSODisassembler
    {
        public static List<LSO.Instruction> Disassemble(byte[] b)
        {
            List<LSO.Instruction> output = new List<LSO.Instruction>();
            LSO.Instruction inst;
            int offset = 0;
            int length = b.Length;
            while (offset < length)
            {
                inst = new LSO.Instruction();
                inst.FromBytes(b, offset);
                output.Add(inst);
                offset += inst.Size;
            }
            return output;
        }

        public static Dictionary<int, LSO.Instruction> DisassembleWithOffsets(byte[] b)
        {
            Dictionary<int, LSO.Instruction> output = new Dictionary<int, LSO.Instruction>();
            LSO.Instruction inst;
            int offset = 0;
            int length = b.Length;
            while (offset < length)
            {
                inst = new LSO.Instruction();
                inst.FromBytes(b, offset);
                output.Add(offset, inst);
                offset += inst.Size;
            }
            return output;
        }
    }
}
